package healththink

import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(FacilityAttributeRating)
@Mock(FacilityAttributeLink)
class FacilityAttributeRatingTests {
	
	@Test
    void testFacilityAttributeRating() {
		
		def farTest = HealthThink.getStaticFacilityAttributeRating()
		mockForConstraintsTests(FacilityAttributeRating, [farTest])
		
		//rating is an int, default is '0'
		def farTest1 = new FacilityAttributeRating()
		farTest1.validate()
		assertFalse farTest1.hasErrors()
		assertTrue farTest1.rating == 0
		assertEquals null, farTest1.errors["rating"]
		
		/* usage test */
		FacilityAttributeRating target = HealthThink.getStaticFacilityAttributeRating()
		assertNotNull("(error)FacilityAttributeRating Target Null", target)
		assertNotNull("(error)FacilityAttributeRating Validation Was Not Successful", target.validate())
		
		target = target.save(flush:true)
		FacilityAttributeRating expected = FacilityAttributeRating.findById(target.id)

		assertNotNull("(error)FacilityAttributeRating Target was not saved", target)
		assertNotNull("(error)Expected FacilityAttributeRating was null", expected)
		assertEquals("(error)Target and Expected are not Equal", target, expected)
		   
		target.delete(flush:true)
    }
}
